const fs = require('fs');
const mongoose = require('mongoose');
const modelDir = __dirname+'/models/';

const files = fs.readdirSync(modelDir);

files.forEach(file=>{
  let [name,sub] = file.split('.');
  console.log(name,sub);
  if(sub === "js"){
    exports[name] =  mongoose.model(name,
                require(modelDir+file));

  }
});
